<?php

function display_posts() {
	global $posts;
	?><div id="content" class="widecolumn"><?

	if ( count($posts) ) :
		foreach ( $posts as $post )  { 
			setup_postdata($post);
			?>
			<div class="post" id="post-<?php the_ID(); ?>">
				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
				<div class="entry">
					<?php the_content('Read the rest of this entry &raquo;'); ?>
				</div>
				<p class="postmetadata">| Posté le <?php the_time('F jS, Y') ?> <?php comments_popup_link('| No Comments &#187;', '| 1 Comment &#187;', '| % Comments &#187;'); ?></p>
			</div>
			<? 
		} 
	else : 
		?>
		<h2 class="center">Not Found</h2>
		<p class="center">Sorry, but you are looking for something that isn't here.</p>
		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
		<? 
	endif; 
	?>
	</div>
	<?
}

function display_pages($posts) {
	?><div id="content" class="widecolumn"><?

	if ( count($posts) ) :
		foreach ( $posts as $post )  { 
			setup_postdata($post);
			?>
			<div class="post" id="post-<?php the_ID(); ?>">
				<h2><?php the_title(); ?></h2>
				<div class="entry">
					<?php the_content('Read the rest of this entry &raquo;'); ?>
				</div>
			</div>
			<? 
		} 
	else : 
		?>
		<h2 class="center">Not Found</h2>
		<p class="center">Sorry, but you are looking for something that isn't here.</p>
		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
		<? 
	endif; 
	?>
	</div>
	<?
}



/* Admin Panel */
function bmg_planning_subpanel() {
  global $wpdb, $table_prefix;
	
  if (isset($_POST['info_update'])) {
  	update_option('last_guest', $_POST['last_guest'], "last_guest");
  	update_option('last_guest_link', $_POST['last_guest_link'], "last_guest_link");
  	update_option('next_guest', $_POST['next_guest'], "next_guest");
  	update_option('bon_plan', $_POST['bon_plan'], "bon_plan");
    ?><div class="updated"><p><strong><?php 
			_e('Options Saved', 'Localization name')
    ?></strong></p></div><?php
	}
	
	// Set BeMyGuest Planning
	?>
	<style>
		fieldset strong {
			width: 175px;
			float:left;
		}
	</style>
	<div class=wrap>
		<form method="post">
	  	<h2>Planning</h2>
	    	<fieldset name="set1">
				<label for='last_guest'><strong>Dernier Invité : </strong></label><input type='text' name='last_guest' id='last_guest' value="<?php echo get_option('last_guest') ?>" style='width:600px'>&nbsp;
				<br />
				<label for='last_guest_link'><strong>Dernier Invité (Lien) : </strong></label><input type='text' name='last_guest_link' id='last_guest_link' value="<?php echo get_option('last_guest_link') ?>" style='width:600px'>&nbsp;
				<br />
				<label for='next_guest'><strong>Prochainement : </strong></label><input type='text' name='next_guest' id='next_guest' value="<?php echo get_option('next_guest') ?>" style='width:600px'>&nbsp;
				<br />
	    		<?if (false) {?>
					<label for='bon_plan'><strong>Bon Plan : </strong></label><input type='text' name='bon_plan' id='bon_plan' value="<?php echo get_option('bon_plan') ?>" style='width:600px'>&nbsp;
				<? } ?>
	     	</fieldset>
			<div class="submit">
	  	<input type="submit" name="info_update" value="<?php _e('Update options', 'Localization name') ?> »" /></div>
	  </form>
	</div>
	<?
}

add_action('admin_menu', 'romina_add_theme_page');

function romina_add_theme_page() {
	add_theme_page('Customize Header', 'Header Image and Color', 'edit_themes', basename(__FILE__), 'romina_theme_panel');
}
function romina_theme_panel() {
  global $wpdb, $table_prefix;
	
  if (isset($_POST['info_update'])) {
  	update_option('header_image', $_POST['header_image'], "header_image");
    ?><div class="updated"><p><strong><?php 
			_e('Options Saved', 'Localization name')
    ?></strong></p></div><?php
	}
	?>
	<style>
		fieldset strong {
			width: 175px;
			float:left;
		}
	</style>
	<div class=wrap>
		<form method="post">
	  	<h2>Header Image</h2>
	    	<fieldset name="set1">
				<label for='last_guest'><strong>Header Image (complete url): </strong></label><input type='text' name='header_image' id='header_image' value="<?php echo get_option('header_image') ?>" style='width:600px'>&nbsp;
	     	</fieldset>
			<div class="submit">
	  	<input type="submit" name="info_update" value="<?php _e('Update options', 'Localization name') ?> »" /></div>
	  </form>
	</div>
	<?
}



?>